//
//  CrossLineLabel.m
//  Ufan
//
//  Created by yangqingluo on 15/11/22.
//  Copyright © 2015年 yangqingluo. All rights reserved.
//

#import "CrossLineLabel.h"

@implementation CrossLineLabel

- (void)drawRect:(CGRect)rect{
    [super drawRect:rect];
    
    
    CGContextRef contex = UIGraphicsGetCurrentContext();
    
    [self.textColor setStroke];
    
    CGFloat y = rect.size.height * 0.5;
    CGContextMoveToPoint(contex, 0, y);
    
    CGSize size = [self.text sizeWithAttributes:@{NSFontAttributeName : self.font}];
    
    CGContextAddLineToPoint(contex, size.width, y);
    
    CGContextStrokePath(contex);
    
//    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(20, 60, 100, 30)];
//    [self.view addSubview:lable];
//    lable.backgroundColor = [UIColor redColor];
//    lable.textAlignment = NSTextAlignmentCenter;
//    NSString *oldPrice = @"¥ 999999";
//    NSUInteger length = [oldPrice length];
//    
//    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:oldPrice];
//    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, length)];
//    [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(0, length)];
//    [lable setAttributedText:attri];
}

@end
